<template>
  <div>
    <div class="local-name">
      设备类型参数
      <el-button
        size="small"
        class="add-button"
        type="success"
        v-if="userGuardList.includes(guard.DeviceParameterManage)"
        @click="showUpload"
      >
        <svg-icon icon-class="add"></svg-icon> 批量导入
      </el-button>
      <el-button
        size="small"
        type="success"
        v-if="userGuardList.includes(guard.DeviceParameterManage)"
        @click="showAdd"
      >
        <svg-icon icon-class="add"></svg-icon> 新建
      </el-button>
    </div>
    <div class="search-form-container">
      <el-form
        :model="searchForm"
        inline
      >

        <el-input
          size="small"
          clearable
          class="search-input"
          v-model="searchForm.name"
          auto-complete="off"
          placeholder="设备类型参数"
        ></el-input>

        <el-button
          size="small"
          type="primary"
          icon="el-icon-search"
          @click="search"
          :loading="searchForm.btnLoading"
        >查询</el-button>
      </el-form>
      <add
        ref="addComponent"
        @refresh="search"
      ></add>
      <upload
        ref="uploadComponent"
        @refresh="search"
      ></upload>
    </div>
  </div>

</template>

<script>
import Add from './add';
import Upload from './upload';

export default {
  components: {
    Add,
    Upload
  },
  model: {
    prop: 'searchForm'
  },
  props: {
    searchForm: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  methods: {
    search() {
      this.$emit('search');
    },
    showAdd() {
      this.$refs.addComponent.showDialog();
    },
    showUpload() {
      this.$refs.uploadComponent.showDialog();
    }
  }
};
</script>

<style lang="scss" scoped>
.local-name {
  padding: 10px 0 10px 10px;
  font-size: 24px;
  font-weight: 800;
  .el-button--success {
    float: right;
    background-color: #2c83b1 !important;
    border-color: #2c83b1 !important;
    margin-right: 10px;
  }
}
.search-form-container {
  background-color: #fff;
  padding: 10px;
  margin: 0 10px 10px 10px;
  .el-select {
    width: 180px;
    margin-right: 10px;
  }
  .search-input {
    width: 180px;
    margin-right: 10px;
  }
  .el-button--primary {
    background-color: #2c83b1 !important;
    border-color: #2c83b1 !important;
  }
}
</style>
